{extend name="public/base"/} {block name="body"}
<style>
.complete-box { height: 100%; margin-bottom: -40px; background: #FFF;}
.complete-wrap { padding:15px 8px 0px; background: #FFF; }
.complete-wrap p.tips,.complete-wrap p.orderno{ font-size: 1.3em; color: #57b174; text-align: left; }

.complete-wrap p.orderno { margin-bottom: 3px; }
.complete-wrap table { margin: 0 auto; }
.complete-wrap table tr td { font-size: 1em; color: #57b174; text-align: left; }
.complete-wrap table tr td img { width: 30px; height: 30px; margin-right: 5px; vertical-align: middle; }
.complete-inner { padding: 10px 8px; margin-top: 15px;  margin-bottom: 50px; background: #f8f8f8; border: solid 1px #dddddd; }
.complete-inner-cancel { border-width: 0; background: none; }
.complete-fruit-box {  margin-bottom: 20px;  }
.complete-fruit-box img { display: block; margin: 0 auto 5px; }
.complete-fruit-box p { font-size: 0.875em; color:  #b2b2b2; text-align: center; }
.complete-top { padding-top: 15px; }
.complete-wrap p.content { display: block; margin-bottom: 20px;  font-size: 1em; color: #696969;  }
.complete-wrap p.content span { color: #57b174; }
.complete-wrap p.hot-line { margin-bottom: 0; color: #b2b2b2; font-size: 0.875em; }
.complete-wrap div.snap-up { font-size: 1.2em; color: #696969; }
.share-btn-cart { display: block; width: 42%; padding: 6px 12px; margin: 0 auto;  font-size: 1.1em; text-align: center;  color: #FFF; background-color: #57b174; border-radius: 2em; }
.share-btn-cart:hover{ text-decoration: none; color: #FFF; }
.complete-wrap div.container-fluid { background: #FFF; }

.navbar-app a.viewMyOrderBtn,.navbar-app a.back2homeBtn { display:inline-block; width: 42%; height: 35px; line-height: 35px; margin-top: 8px; font-size: 1em; color: #FFF; text-decoration: none; }
.navbar-app a.viewMyOrderBtn { background-color: #ff8135; }
.navbar-app a.viewMyOrderBtn:hover,.navbar-app a.back2homeBtn:hover,.navbar-app a.viewMyOrderBtn:active,.navbar-app a.back2homeBtn:active { color: #FFF; }
.navbar-app a.back2homeBtn { margin-right: 5%; background-color: #57b174;  }
.btn_complete_know { color: #FFFFFF; }
.btn_complete_know:hover,.btn_complete_know:active { color: #FFFFFF;}

.complete-footer { width: 100%; height: 50px;  background: #fcfaec; }
.complete-footer-inner { width: 90%; margin: 0 auto; text-align: center; }
</style>
<header class="mui-bar mui-bar-nav" style="z-index:7">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">微信付款</h1>
</header>
<div class="mui-content ">
  <div class="complete-wrap" style="" >
		<div align="center">
			<p style="margin:20px auto;font-size:20px;">鲜果屋订单支付金额为{$info.pay_price}元 </p>
			<p style="font-size:24px;color:red;">￥{$info.pay_price}</p>
			<div style="background-color:#fff;border:1px solid #ebebeb;line-height:30px;">
				<p>收款方：鲜果屋 </p>
				<p>商品名称：{$info.title}</p>
			</div>
			<button style="margin-top:40px;width:90%; height:50px; border-radius: 15px;background-color:#26a731; border:1px #26a731 solid; cursor: pointer;  color:white;  font-size:16px;" type="button" onclick="callpay()" >立即支付</button>
		</div>
	</div>
</div>

{/block}
{block name="script"}
  <script type="text/javascript">

  $(function(){
      $('.complete-wrap').height($(window).height()-46)
  })
  //调用微信JS api 支付
	function jsApiCall()
	{
		WeixinJSBridge.invoke(
			'getBrandWCPayRequest',
			{$options},
			function(res){
				WeixinJSBridge.log(res.err_msg);
         if(res.err_msg == "get_brand_wcpay_request:ok" ) {
            mui.toast('支付成功')
            window.location.href = "{:url('order/index', array('orderid'=>$info['id']))}"
        }else if (res.err_msg == "get_brand_wcpay_request:cancel" ) {
          mui.toast('取消支付')
        }else{
          //mui.toast('支付失败，请重新或联系我们')
         mui.toast(res.err_code+'&'+res.err_desc+'&'+res.err_msg)
        }
        //  mui.toast(res.err_code+'&'+res.err_desc+'&'+res.err_msg)
        //mui.toast(res.err_msg)
			}
		);
	}

	function callpay()
	{
		if (typeof WeixinJSBridge == "undefined"){
		    if( document.addEventListener ){
		        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', jsApiCall);
		        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		    }
		}else{
		    jsApiCall();
		}
	}


  $(function(){
      pushHistory();
      var bool=false;
      setTimeout(function(){
            bool=true;
      },1500);
      window.addEventListener("popstate", function(e) {
        if(bool)
          {

                  location.href="{:url('index/order/index')}";
          }
          pushHistory();

        }, false);
  });
  function pushHistory() {
    var state = {
        title: "title",
        url: "#"
    };
    window.history.pushState(state, "title", "#");
  }


  </script>
{/block}
